// ==UserScript==
// @name         双色球中奖显示
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Xirtam
// @match        https://www.cwl.gov.cn/ygkj/wqkjgg/ssq/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $(document).ready(function() {
        $('body').prepend('<input type="button" value="检测" id="button">');
        $("#button").on("click", function(){

            var buy_red = ['9', '13', '16', '17', '18', '22']
            var buy_blue = '11'

            console.log('start')
            var qius = document.getElementsByClassName('qiu-item qiu-item-small qiu-item-wqgg-zjhm-blue');
            for (var i=0; i<qius.length; i++) {
                var reds = qius[i].parentNode.getElementsByClassName('qiu-item qiu-item-small qiu-item-wqgg-zjhm-red')

                var redNum = 0
                var blueNum = 0

                for (var ir=0; ir < 6; ir++){
                    //console.log('reds ' + reds[ir].innerText)
                    for (var ib=0; ib < 6; ib++){
                        if (reds[ir].innerText == buy_red[ib]){
                            redNum = redNum + 1
                            //console.log('数字 ' + reds[ir].innerText +' 在 ' + buy_red)
                        }
                    }
                }

                //console.log('blue ' + qius[i].innerText)
                if (qius[i].innerText == buy_blue){
                    blueNum = blueNum + 1
                }
                //console.log('红'+redNum+'，蓝'+blueNum)
                if (blueNum == 1 || redNum>=3){
                    //console.log('中')
                    var qi = qius[i].parentNode.parentNode.parentNode.firstChild
                    qi.innerText = qi.innerText + ' 中了' + redNum + '+' + blueNum
                }
            }
            $('body').prepend('<input type="button" value="检测完成" id="butokton">');
        });
    });
})();